import { ESpecimenStatus } from "@scmt/api-common";
import { SpecimenEntity } from "@scmt/api-lis-specimen";

const _selectSpecimens = ref<SpecimenEntity[]>([]);
const _currentSpecimen = ref<null | SpecimenEntity>(null);
const _specimenStatus = ref<ESpecimenStatus>(ESpecimenStatus.NOTGENERATED);

// 当前页面标本状态
export const useSpecimenStatus = () => {
  const specimenStatus = computed(() => _specimenStatus.value);

  const updateSpecimenStatus = (status: ESpecimenStatus) => {
    _specimenStatus.value = status;
  };

  return {
    specimenStatus,
    updateSpecimenStatus,
  };
};

// 列表选中的标本
export const useSelectSpecimens = () => {
  const selectSpecimens = computed(() => _selectSpecimens.value);

  const updateSelectSpecimens = (specimens: SpecimenEntity[]) => {
    _selectSpecimens.value = specimens;
  };

  return {
    selectSpecimens,
    updateSelectSpecimens,
  };
};

// 当前编辑的标本
export const useCurrentSpecimen = () => {
  const currentSpecimen = computed(() => _currentSpecimen.value);

  const updateCurrentSpecimen = (specimen: SpecimenEntity) => {
    _currentSpecimen.value = specimen;
  };
  return {
    currentSpecimen,
    updateCurrentSpecimen,
  };
};
